package com.mingqijia.gassafety.webserver.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.mingqijia.gassafety.authority.api.resp.config.DictionaryItemRespDTO;
import com.mingqijia.gassafety.db.entity.Consumer;
import com.mingqijia.gassafety.db.entity.Contacts;
import com.mingqijia.gassafety.db.entity.FuncArea;
import com.mingqijia.gassafety.shared.utils.commonUtils.PageUtil;
import com.mingqijia.gassafety.webserver.request.*;
import com.mingqijia.gassafety.webserver.request.inner.AddressTurnCoordinateReq;
import com.mingqijia.gassafety.webserver.response.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户表 服务类
 * </p>
 *
 * @author wanghai
 * @since 2022-02-22
 */
public interface ConsumerService extends IService<Consumer> {

    /**
     * 条件分页查询
     * @param request
     * @return
     */
    PageUtil<ConsumerResponse> consumerList(ConsumerListRequest request);

    /**
     * 条件分页查询
     * @param request
     * @return
     */
    PageUtil<ConsumerResponse> consumerListAsst(ConsumerListRequest request);

    /**
     * 根据客户id得到客户详情
     * @param consumerId
     * @return
     */
    ConsumerDetailResponse detail(String consumerId);

    /**
     * 新增客户信息
     * @param request
     */
    Integer addConsumer(ConsumerRequest request);

    Integer addConsumer(ConsumerRequest request,String spId);

    /**
     * 删除客户信息
     * @param consumerId
     */
    void deleteConsumer(String consumerId);

    /**
     * 维护客户基本信息
     * @param request
     */
    String editConsumer(ConsumerRequest request);

    /**
     * 更新燃气户信息
     * @param request
     * @return
     */
    String updateSubsInfo(ConsumerUpdateSubsInfoRequest request);

    /**
     * 维护客户联系人信息
     * @param request
     */
    void editContacts(ContactsEditRequest request);

    List<ContactsResponse>  contactsListByConsumer(ContactsEditRequest request);

    /**
     * 客户设备关联
     * @param request
     */
    void bindingEquipment(ConsumerBindingRequest request);

    /**
     * 导入客户设备关联
     * @param request
     */
    void importBindingEquipment(ConsumerBindingRequest request);

    /**
     * 批量导入安装发起
     * @param request
     */
    void importAZBindingEquipment(ConsumerBindingRequest request);

    /**
     * 客户设备关联
     * @param request
     */
    void bindingOrderEquipment(ConsumerBindingRequest request);

    /**
     * 客户设备关联
     * @param request
     */
    void bindingEquipmentZJ(ConsumerBindingRequest request);

    /**
     * 客户设备 解除关联
     * @param request
     */
    void unbindEquipment(ConsumerunBindingRequest request);

    /**
     * 客户设备 解除关联
     * @param request
     */
    String unbindEquipmentOrder(ConsumerunBindingRequest request);

    /**
     * 非wifi客户设备 解除关联
     * @param request
     */
    void unbindMember(ConsumerunBindingRequest request);


    /**
     * 客户设备 解除关联, 时刻助手渠道
     * @param request
     */
    void unbindEquipmentAsst(ConsumerunBindingRequest request);

    /**
     * 设备基础信息
     * @param imei
     * @return
     */
    EquipmentInfoResponse equipmentInfo(String imei);

    /**
     * 控制器-通讯记录
     * @param request
     * @return
     */
    PageUtil<DtuMeasureLogResponse> dtuMeasureLog(EquipmentLogRequest request);

    /**
     * 探测器部分-通讯记录
     * @param request
     * @return
     */
    PageUtil<DetectorMeasureLogResponse> detectorMeasureLog(EquipmentLogRequest request);

    /**
     * 批量删除客户
     * @param request
     */
    void batchDeleteConsumer(List<String> request);

    /**
     * 导入客户
     * @param file
     */
    HashMap<String, List<String>> importData(MultipartFile file);
    /**
     * 导入客户-异步
     * @param file
     */
    String importDataSync(MultipartFile file);

    /**
     * 校验户号是否已存在
     */
    List<String> checkSubsCode (String subsCode, String spId);

    Integer consumerImportAdd( List<Object> objects, int offset, Integer bindChannel);
    Integer consumerImportAdd( List<Object> objects, int offset, Integer bindChannel,String spId,Map<String, FuncArea> funcAreaMap);

    /**
     * 根据户号查询户表信息
     * @param subsCode
     * @return
     */
    VccUserRseponse getVccUser(String subsCode,String spId,String orgCode);

    String updateVccUser(String subsCode, String consumerId);

    /**
     * 客户列表
     * @param request
     * @return
     */
    PageUtil<CustListResponse> custList(CustListRequest request);


    PageUtil<CustListResponse> custListAsst(CustListRequest request);



    String dictionaryname(String value, String dictCode );

    /**
     * 客户列表- 右侧信息
     * @param request
     * @return
     */
    ConsumerDetailResponse custDetail(CustDetailRequest request);

    /**
     * 绑定设备时, 注册余杭设备
     * @param spId
     * @param imei
     */
    void registerCityDevice(String spId, String imei);

    HashMap<String, List<String>>  batchImportWorkOrder(MultipartFile file);


    /**
     *  异步导入
     * @param file
     * @return
     */
    String batchImportWorkOrderSync(MultipartFile file);

    /**
     * 通讯记录_接收器&电磁阀记录列表
     * @param request
     * @return
     */
    PageUtil<ReceiverValveLogResponse> receiverMeasureLog(EquipmentLogRequest request);

    List<DictionaryItemRespDTO> getIndustryTypeList();

    Integer installImportAdd(List<Object> objects, int offset, Integer bindChannel,Map<String,FuncArea> funcAreaMap);

    Integer installImportAdd(List<Object> objects, int offset, Integer bindChannel,String spId);

    /**
     * 客户列表
     * @param request
     * @return
     */
    PageUtil<CustListResponse> custListV2(CustListRequest request);

    /**
     * 根据客户id得到客户详情
     * @param consumerId
     * @return
     */
    List<ConsumerResponse> batchDetail(ConsumerDetailRequest request);
    /**
     * 解绑设备同步到tcis
     * @param request
     * @param spId
     */
    void unbindEquipmentToTcis(NewAsstUnbindRequest request,String spId);

    /**
     * 同步客户表中坐标
     */
    void syncConsumer();

    /**
     * 批量更新客户坐标code
     */
    void updateConsumer(List<Consumer> consumerList);

    /**
     * 获取客户关联的spid
     * @param consumerId
     * @param originSpId
     * @return
     */
    String getConsumerRelateSpId(Integer consumerId, String originSpId);

    //客户列表数量
    Map<String, Integer> getConditionList();

    /**
     * 更新客户户主联系人信息
     * @param consumer
     */
    void updateContacts(Consumer consumer);

    /**
     * 根据地址修改坐标和编码
     */
    void addressTurnCoordinate(AddressTurnCoordinateReq req);
}
